using System.Web;
using CKS.EBE.API;
using Microsoft.SharePoint;
using System.Globalization;

namespace CKS.EBE
{
    public class RssHandler : IHttpHandler
    {

        #region IHttpHandler Members

        public bool IsReusable
        {
            get { return true; }
        }

        public void ProcessRequest(HttpContext context)
        {
            SPWeb web = SPContext.Current.Web;
            SPList oPosts = Helper.GetListByFolderName(web, Localization.GetListName(Localization.BlogList.Posts, SPContext.Current.Web.Language));

            context.Response.Clear();

            context.Response.AppendHeader("ETag", oPosts.CurrentChangeToken.ToString());
            context.Response.AppendHeader("Last-Modified", oPosts.LastItemModifiedDate.ToString("r", CultureInfo.InvariantCulture));
            context.Response.ContentType = "text/xml";

            context.Response.Write(RssFeed.GetFeed());
            context.Response.End();
        }

        #endregion
    }
}
